﻿@model IEnumerable<Wicresoft.UnifyShow.Business.OSModel>
@{
    ViewBag.Title = "维护操作统";
    var types = new Wicresoft.UnifyShow2.Portal.ViewModels.DeviceAndTypes().Types;
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
    Dictionary<decimal, string> idAndSiteNames = (Dictionary<decimal, string>)ViewData["SiteIDAndName"];
    List<decimal> listSiteIDs = Model.Select(o => o.ID).Distinct().OrderBy(o => o).ToList();
}
@section ScriptAndCss{
    <link href="../../Content/jquery.treeview.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/css/bsadmin.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery.cookie.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.treeview.js" type="text/javascript"></script>
    <script src="../../Scripts/ALL.js" type="text/javascript"></script>
    <script type="text/javascript">
        function initTheEditor() {
            $("#osSave", "#content").click(function () {
                $.post("@Url.Action("Edit", "AdminOS")",
                          $("#osEditForm").serialize() + "&Name=" + $("#osName", "#osEditForm").val(),
                          function () {
                              alert("更新成功");
                              var url = "@Url.Action("Tree", "AdminOSMaintain")";
                              $("#tree").load(url, function () {
                                  treeView();
                              });
                          });
            });
            $("#osPublish", "#content").click(function () {
                $.post("@Url.Action("Publish", "AdminOS")",
                          "id=" + $("#osID", "#osEditForm").val(),
                          function () {
                              alert("发布成功");
                          });
            });
            $("#osDelete", "#content").click(function () {
                var isContinue = confirm("你确定要删除此业务系统？");
                if (isContinue) {
                    $.post("@Url.Action("Delete", "AdminOS")",
                              "id=" + $("#osID", "#osEditForm").val(),
                              function () {
                                  alert("删除成功");
                                  var url = "@Url.Action("Tree", "AdminOSMaintain")";
                                  $("#tree").load(url, function () {
                                      treeView();
                                  });
                              });
                }
            });
        }
        
        function treeView(){
             $("#osTree").treeview({
                control: "#osTreeControl",
                persist: "cookie",
                cookieId: "treeview-black_OSTreeMaintaince",
                collapsed: true,
                unique: true
              });
             
            $(".node").click(function (e) {
                var id = $(this).attr("data-id");
                var url="@Url.Action("Edit", "AdminOS")"+"?osID="+id;
                $("#content").load(url,function()
                {
                initTheEditor();
                });
                $("#osID").val(id);
                e.preventDefault();
            });
                  $("#content").empty();
        }
       $(function () {
            treeView();
         });
    </script>
}
<div class="index_lr">
    <input type="hidden" id="osID" />
    <ul>
        <li class="index_lr4_L">
            <div id="tree">
                @Html.Action("Tree")
            </div>
        </li>
        <li class="index_lr4_R">
            <ul>
                <li class="index_lr4_R">
                    <div class="index_lrA_title ui-icons">
                        <h3>
                            操作系统：</h3>
                    </div>
                    <div id="content">
                    </div>
                </li>
            </ul>
</div>
<div class="clear">
</div>